{extend name="index/index"/}

{block name="main"}

<div class="admin-biaogelist">

    <div class="listbiaoti am-cf">
        <ul class="am-icon-flag on"> {$title}</ul>
        <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#">评论管理列表</a></dl>
    </div>

    <!--订单评论列表-->
    <form class="am-form am-g">
        <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
            <thead>
            <tr class="am-success">
                <th class="table-id am-text-center">ID</th>
                <th class="table-title">商品名称</th>
                <th class="table-type">商品评论</th>
                <th class="table-author am-hide-sm-only">评论时间</th>
                <th width="125px" class="table-set">操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="comment" id="vo"}
            <tr>
                <td class="am-text-center">{$vo.id}</td>
                <td><a href="#">{$vo.house_name}</a></td>
                <td>{$vo.commentinfo}</td>
                <td class="am-hide-sm-only">{$vo.comment_time}</td>
                <td><div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <a href ="{:url('admin/comment/create',['id' => $vo['id']])}" class="am-btn am-btn-default am-btn-xs am-text-secondary am-round" data-am-modal="{target: '#my-popups'}" title="商家回复"><span class="am-icon-pencil-square-o" ></span></a>
                        <!-- 用按钮的时候 弹层 后缀需要加 问好 ？#的 时候才有效 真恶心 .html?# -->
                        <button data-id="{$vo['id']}" class="am-btn am-btn-default am-btn-xs am-text-danger am-round btn-del"  title="删除"><span class="am-icon-trash-o"></span></button>
                    </div>
                </div></td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </form>
    <ul class="am-pagination am-fr">
        {$comment->render()}
    </ul>
    <!--订单评论列表结束-->





</div>
<script>
    $(function(){
        //触发用户的删除操作
        $('.btn-del').click(function(){
            var ac_id = $(this).attr('data-id');
            console.log('删除操作的id为:',ac_id);

            if(confirm('你确定要删除该评论吗？')){
                var obj = $(this).parents('tr');
                console.log(obj);

                //调用ajax进行删除
                delAjax(ac_id,obj);
            }
        });

        //执行ajax删除
        function delAjax(id,obj){
            $.ajax({
                type : 'delete',      //delete 删除方式
                url : '/admincomment/'+id,
                dataType : 'json',
                success : function(data){
                    console.log(data);
                    if (data.status) {
                        alert(data.info);
                        // 将当前的节点删除掉
                        obj.remove();
                    } else {
                        alert(data.info);
                    }
                },
                error : function(){
                    //ajax操作失败
                    alert('ajax请求失败');
                }


            })
        }

    });

</script>
{/block}